﻿using Microsoft.CodeAnalysis;

namespace RoslynProxy.SourceGenerator
{
    [Generator]
    internal class ProxyServiceSourceGenerator : ISourceGenerator
    {
        private readonly RoslynProxyServiceTypeBuilder _builder = new RoslynProxyServiceTypeBuilder();

        public void Execute(GeneratorExecutionContext context)
        {
            if (_builder.TryBuildSource(context.Compilation, out var typeInfo))
            {
                context.AddSource(typeInfo.ClassName + ".g.cs", typeInfo.Source);
            }
        }

        public void Initialize(GeneratorInitializationContext context)
        {
        }
    }
}
